package com.mym.test;

import java.util.Objects;

/**
 * @author miao
 * @version 1.0
 * @date 2025/4/12 13:42
 * @description
 */
public abstract class   Pet {
    private String name;
    private int health;
    private int age;

    public Pet() {
    }

    public Pet(String name, int health, int age) {
        this.name = name;
        this.health = health;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getHealth() {
        return health;
    }

    public void setHealth(int health) {
        this.health = health;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pet pet = (Pet) o;
        return health == pet.health && age == pet.age && Objects.equals(name, pet.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, health, age);
    }

    @Override
    public String toString() {
        return "Pet{" +
                "name='" + name + '\'' +
                ", health=" + health +
                ", age=" + age +
                '}';
    }
    public abstract void Eat();
    public abstract void Show();
}
class Dog extends Pet{
    private String type;

    public Dog(String name, int health, int age) {
        super(name, health, age);
    }

    public Dog(String name, int health, int age, String type) {
        super(name, health, age);
        this.type = type;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Override
    public void Eat() {
        System.out.println("吃东西");

    }

    @Override
    public void Show() {
        System.out.println(getName()+getHealth()+getHealth()+getType());
    }
}
class Pengunin extends Pet{
    private String nex;

    public Pengunin(String name, int health, int age) {
        super(name, health, age);
    }

    public Pengunin(String name, int health, int age, String nex) {
        super(name, health, age);
        this.nex = nex;
    }

    public String getNex() {
        return nex;
    }

    public void setNex(String nex) {
        this.nex = nex;
    }

    @Override
    public void Eat() {
        System.out.println("吃东西");
    }

    @Override
    public void Show() {
        System.out.println(getName()+getHealth()+getAge()+getNex());
    }
}
